import React, { Component } from 'react';
import MuiAlert from '@material-ui/lab/Alert';
import { connect } from 'react-redux'
import './alert.less'

class Alert extends Component {
  render() {
    return (
      <div>
        <MuiAlert style={{ display: this.props.showAlert ? 'flex' : 'none' }} elevation={6} variant='filled' severity={this.props.alertType} className='my-mui-alert'>{this.props.alertContent}</MuiAlert>
      </div>
    );
  }
}
// stateToProps是一种映射关系，把原来的state映射成组件的props属性
const stateToProps = (state) => {
  return {
    showAlert: state.showAlert,
    alertType: state.alertType,
    alertContent: state.alertContent
  }
}
export default connect(stateToProps, null)(Alert);